#pragma once

///Class managing an OpenGL Frame buffer.
class								FrameBuffer
{
	public:
		///Create a new FrameBuffer object.
		///@param aWidth Width of the FrameBuffer, in pixels.
		///@param aHeight Height of the FrameBuffer, in pixels.
		///@param aDepthBuffer Enable a depthbuffer.
									FrameBuffer				(uint32_t aWidth, uint32_t aHeight, bool aDepthBuffer = false);

		///Destroy a FrameBuffer object.
									~FrameBuffer			();

		///Get the width of the FrameBuffer.
		///@return The width of the FrameBuffer, in pixels.
		uint32_t					GetWidth				() const {return Width;};

		///Get the height of the FrameBuffer.
		///@return The height of the FrameBuffer, in pixels.
		uint32_t					GetHeight				() const {return Height;};

		///Enable or disable bi-linear filtering for the FrameBuffer.
		///@param aOn New state of the FrameBuffer filter.
		void						SetFilter				(bool aOn) {Filter = aOn;}

	public: //Helper, do not call directly
		///Apply the FrameBuffer as the active OpenGL texture.
		void						Apply					();

		///Get the OpenGL texture ID for this FrameBuffer.
		///@return The ID of the texture, generated by glGenTextures.
		uint32_t					GetID					() const {return ID;}

		///Get the OpenGL renderbuffer ID for the depth buffer.
		///@return The ID of the texture, generated by glGenTextures.
		uint32_t					GetDepthID				() const {return DepthID;}

	private:
		uint32_t					ID;						///The Texture's OpenGL texture ID.
		uint32_t					DepthID;				///ID of the Depth Buffer.

		uint32_t					Width;					///The width of the Texture in pixels.
		uint32_t					Height;					///The height of the Texture in pixels.
		bool						Filter;					///Determine if the texture uses bi-linear filtering.
		bool						Valid;					///False if the texture needs its pixels re-uploaded when applied.
};


